package com.sunfeng;

import java.nio.CharBuffer;

/**
 * @description:
 * @author: 孙 峰
 * @time: 2020/11/5 20:44
 */
public class Test2 {
    public static void main(String[] args) {
        char[] chars = new char[]{'a', 'b', 'c', 'd','e'};
        CharBuffer charBuffer = CharBuffer.wrap(chars);
        System.out.println("A capacity()="+charBuffer.capacity());
        System.out.println("A limit()="+charBuffer.limit());
        charBuffer.limit(3);

        System.out.println("B capacity()="+charBuffer.capacity());
        System.out.println("B limit()="+charBuffer.limit());
        charBuffer.put(0,'o');//0
        charBuffer.put(1,'p');//0
        charBuffer.put(2,'q');//0
        charBuffer.put(3,'r');//0
        charBuffer.put(4,'s');//0
        charBuffer.put(5,'t');//0
        charBuffer.put(6,'u');//0
        System.out.println(charBuffer.toString());
    }
}
